<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../../common/jsp/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>角色权限配置</title>
<%@ include file="../../../common/jsp/config.jsp"%>
<script type="text/javascript">
function changePermissions(roleId, moduleId){
	var image = $("#img_" + roleId + "_" + moduleId);
	var data = "roleId=" + roleId + "&moduleId=" + moduleId + "&temp=" + new Date();
	$.ajax({
	   url: "changePermissions.action",
	   data: data,
	   success: function(json){
	   	   var imageSrc = image.attr("src");
	   	   if (imageSrc == "common/images/permissions_apply.png") {
	   	   	   image.attr("src", "common/images/permissions_close.png");
	   	   } else {
	   	   	   image.attr("src", "common/images/permissions_apply.png");
	   	   }
	   }
	});
}
</script>
</head>
<body>
    <div class="subnav" align="left">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">系统管理</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">角色权限配置</span></td>
		  </tr>
		</table>
      </div>
<div class="main_1">
  <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D3DEEF">
    <tr align="left">
      <td bgcolor="#FFFFFF">
        <s:form action="roleModuleConfig">
      	<table width="100%" border="0" cellspacing="1" cellpadding="2">
        <tr>
          <td width="13%" align="right">权限分类</td>
          <td width="20%">
          	<s:select name="parentModuleId"
          		list="rootModules"
          		listKey="id"
          		listValue="name"
          		headerKey="-1"
          		headerValue="-请选择-" />
          <td width="15%" align="right">
            <s:submit value="查询" cssClass="input1" />
          </td>
        </tr>
        </table>
        </s:form>
      </td>
    </tr>
  </table>
</div>
<s:actionerror cssStyle="color:red"/>
<div class="main_scroll">
<div class="ksglxx2">
  <table width="850px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <tr class="ksglxx2bg">
          <th width="150px" align="center">&nbsp;</th>
          <s:iterator value="roleList" id="role" status="st">
           <th width="50px" align="center"><s:property value="#role.name" /></th>
          </s:iterator>
        </tr>
   </table>
   <table width="850px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <s:iterator value="moduleList" id="module" status="st">
          <s:if test="#st.Odd">
            <tr class="odd">
          </s:if>
          <s:else>
            <tr class="even">
          </s:else>
              <td width="150px"><s:property value="#module.name" /></td>
	          <s:iterator value="roleList" id="role" status="rst">
	           <td width="50px" align="center">
	             <a class="b" href='javascript:changePermissions(<s:property value="#role.id" />,<s:property value="#module.id" />)'>
                  <s:if test="#module.id in #role.moduleIds">
                    <img id='img_<s:property value="#role.id" />_<s:property value="#module.id" />' src="common/images/permissions_apply.png" border="0" align="absmiddle" />
                  </s:if>
                  <s:else>
                    <img id='img_<s:property value="#role.id" />_<s:property value="#module.id" />' src="common/images/permissions_close.png" border="0" align="absmiddle" />
                  </s:else>
                 </a>
	           </td>
	          </s:iterator>
            </tr>
         </s:iterator> 
  </table>
</div>
</body>
</html>
